import request from '@/api/request'

function check() {
  
  plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
    let platform = plus.os.name.toLocaleLowerCase()
	request.get('system/config/configKey/app/'+ platform).then(result => {
		let data = result.data ? result.data : null
		console.log('app-data',data.data);
		console.log('version',JSON.parse(data.data.configValue).version);
		if(data.code == 200){
			if (widgetInfo.version === JSON.parse(data.data.configValue).version) {
				return
			}
			/**
			 * 携带数据跳转升级弹框
			 */
			uni.navigateTo({
				url: `/components/check-page/upgrade-popup?version=${JSON.parse(data.data.configValue).version}&oldVersion=${widgetInfo.version}&upReason=${data.data.remark}&url=${JSON.parse(data.data.configValue).url}&platform=${platform}`,
				fail: (err) => {
					console.error('更新弹框跳转失败', err)
				}
			})
		}
	})
	
  })
}

export default {
  check
}
